package com.fulihui.wgj.service.game;

import com.alibaba.dubbo.config.annotation.Service;
import com.fulihui.common.builder.rpc.RpcResultBuilder;
import com.fulihui.common.error.InvokeServiceException;
import com.fulihui.common.result.rpc.SimpleResult;
import com.fulihui.common.util.ConditionValidator;
import com.fulihui.wgj.dal.impala.mapper.UserGameBehaviorMapper;
import com.fulihui.wgj.facade.request.game.GameBehaviorQueryRequest;
import com.fulihui.wgj.facade.service.game.GameBehaviorService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 游戏用户行为服务
 *
 * @author wang_wx
 * @date 2018-08-06
 */
@Component
@Service(interfaceClass = GameBehaviorService.class, version = "1.0.0", timeout = 6000)
public class GameBehaviorServiceImpl implements GameBehaviorService {

    @Resource
    UserGameBehaviorMapper userGameBehaviorMapper;

    @Override
    public SimpleResult<Long> queryBehaviorMoney(GameBehaviorQueryRequest request) throws InvokeServiceException {
        ConditionValidator.validate(request);
        String openId = request.getOpenId();
        String secondTag = request.getSecondTag();
        Long money = userGameBehaviorMapper.selectMoney(openId, secondTag);
        return RpcResultBuilder.succSimple(money);
    }
}
